{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6efbfb16",
   "metadata": {},
   "source": [
    "# 函数\n",
    "函数是组织好的，可重复使用的，用来实现单一，或相关联功能的代码段。\n",
    "\n",
    "函数能提高应用的模块性，和代码的重复利用率。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "0489ec82",
   "metadata": {},
   "outputs": [],
   "source": [
    "'''\n",
    "函数头部应进行注释，列出：函数的目的/功能、输入参数、输出参数、返回值、调用关系（函数、表）等。\n",
    "\n",
    "示例：下面这段函数的注释比较标准，当然，并不局限于此格式，但上述信息建议要包含在内。\n",
    "/*************************************************\n",
    "Function: // 函数名称\n",
    "Description: // 函数功能、性能等的描述\n",
    "Calls: // 被本函数调用的函数清单\n",
    "Called By: // 调用本函数的函数清单\n",
    "Table Accessed: // 被访问的表（此项仅对于牵扯到数据库操作的程序）\n",
    "Table Updated: // 被修改的表（此项仅对于牵扯到数据库操作的程序）\n",
    "Input: // 输入参数说明，包括每个参数的作// 用、取值说明及参数间关系。\n",
    "Output: // 对输出参数的说明。\n",
    "Return: // 函数返回值的说明\n",
    "Others: // 其它说明\n",
    "'''\n",
    "'''\n",
    "函数名：add\n",
    "描述：两个整数求和\n",
    "输入：两个int类型的整数\n",
    "返回值：int类型\n",
    "'''\n",
    "def add(x:int, y:int)->int:\n",
    "    # code to do\n",
    "    return x+y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d97de688",
   "metadata": {},
   "outputs": [],
   "source": [
    "# lambda [arg1 [,arg2,.....argn]]:expression\n",
    "#lambda函数/表达式\n",
    "#比较简单的函数可以这样写\n",
    "my_sum = lambda a, b: a + b\n",
    "print(my_sum(2, 3))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
